﻿<!DOCTYPE html>
<html>
<head>
    <title>CGI</title>
</head>
<body>
    <h1>Our Page</h1>
    <script>
        //01
        //here secretProject is a brand new object and it's prototype set to be project (our own object)
        //secretProject.securityLevel not available in secretProject object, it's find from it's prototype project

        var project = {
            securityLevel: 2
        };
        var secretProject = Object.create(project);
        console.log(secretProject.securityLevel);


        //02
        //walking through prototype chain
        //secretProject doesn't have toString function
        //and it's prototype doesn't have toString function
        //but prototype's prototype does have it (Object.prototype)
        /*
        var project = {
            securityLevel: 2
        };
        var secretProject = Object.create(project);
        console.log(typeof secretProject.toString);
         */

        //03
        //secretProject has it's prototype sets to project and project has it's prototype sets to Object.prototype
        /*
        var project = {
            securityLevel: 2
        };
        var secretProject = Object.create(project);
        console.log(secretProject.__proto__.__proto__ === Object.prototype);
        */
    </script>
</body>
</html>